package com.glorystone.director;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by admin on 2017/6/30.
 */
@Component
public class Producer {

    @Autowired
    private AmqpTemplate rabbitTemplate;


    public void send() {
        String context = "hello " + new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        System.out.println("Sender : " + context);
        for(int i=0;i<20;i++) {
            this.rabbitTemplate.convertAndSend("hello", context+"_"+i);
        }
    }

}
